
layui.use(['layer', 'form', 'admin', 'ax','formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;
    var formSelects = layui.formSelects;
    admin.iframeAuto();


    form.on('submit(btnSubmit)', function (data) {
        var path_ = "/sam/lessee/add.json";
        if(data.field.id!=''){
            path_ = "/sam/lessee/edit.json";
        }
        if(data.field.status=='on'){
            data.field.status=1;
        }else{
            data.field.status=0;
        }
        var ajax = new $ax(Sam.ctxPath+path_, function (data) {
            Sam.success("保存成功！");
            admin.putTempData('formOk', true);
            admin.closeThisDialog();
        }, function (data) {
            Sam.error("保存失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
    });
});